version: '3'

services:
  django:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: django
    command: sh -c "mkdir -p /usr/src/app/turiki_app/migrations && touch /usr/src/app/turiki_app/migrations/__init__.py && python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
    volumes:
      - .:/usr/src/app
    ports:
      - "8000:8000"
    depends_on:
      - pgdb
      - redis
      - rabbit
      - dramatiq
  redis:
    image: redis:5
    ports:
      - "6379:6379"
  rabbit:
    image: rabbitmq:3-management
    ports:
      - "5672:5672"
      - "15672:15672"
    depends_on:
      - redis
    restart: unless-stopped
  pgdb:
    # Использование готового образа postgres
    image: postgres:latest
    # Задание переменных окружения для контейнера с postgres
    environment:
      - POSTGRES_DB=TurikiCore
      - POSTGRES_USER=$PG_USER
      - POSTGRES_PASSWORD=$PG_PASSWORD
      # Задание имени контейнера для сервиса pgdb
    container_name: pgdb
    ports:
      - "5432:5432"
  pgadmin:
    container_name: pgadmin
    image: dpage/pgadmin4
    environment:
      - PGADMIN_DEFAULT_EMAIL=fedorgugnin22@gmail.com
      - PGADMIN_DEFAULT_PASSWORD=Fedor_223
    ports:
      - "5050:80"
  dramatiq:
    volumes:
      - .:/usr/src/app
    build:
      context: .
      dockerfile: Dockerfile
    command: sh -c "python manage.py rundramatiq --processes 6 --threads 6"
    depends_on:
      - redis
      - rabbit